package com.lgs.demo.customview;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lgs.demo.R;

/**
 * Created by lgs on 2018/3/12.
 */

public class ImageBtn extends LinearLayout {

    private ImageView ivBTC;
    private TextView tvVolume;

    public ImageBtn(Context context) {
        super(context);
        init(context);
    }

    public ImageBtn(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public ImageBtn(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.layout_image_text, this);
        ivBTC = (ImageView) findViewById(R.id.imageView1);
        tvVolume = (TextView) findViewById(R.id.textView1);
    }

    /**
     * 设置图片资源
     *
     * @param resId
     */
    public void setImageResource(int resId) {
        ivBTC.setImageResource(resId);
    }

    /**
     * 设置显示的文字
     *
     * @param text
     */
    public void setText(String text) {
        tvVolume.setText(text);
    }
}
